//
//  XJGoodsDetailCommentCollectionViewCell.m
//  XinJiangMall
//
//  Created by Tzyang on 2018/4/11.
//  Copyright © 2018年 Tzyang. All rights reserved.
//

#import "XJGoodsDetailCommentCollectionViewCell.h"
#import "UIImage+ColorImage.h"

@interface XJGoodsDetailCommentCollectionViewCell ()

@property (nonatomic ,strong) UIImageView * xjgdCommentIconImgV;//头像
@property (nonatomic ,strong) UILabel * xjgdCommentUserNameLab;//昵称
@property (nonatomic ,strong) UILabel * xjgdCommentContentLab;//内容
@property (nonatomic ,strong) UILabel * xjgdCommentTimeLab;//时间
@property (nonatomic ,strong) UILabel * xjgdCommentSpeLab;//套餐、颜色

@end

@implementation XJGoodsDetailCommentCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = WHITE_COLOR;
        [self setupSubviews];
    }
    return self;
}

- (UIImageView *)xjgdCommentIconImgV{
    if (!_xjgdCommentIconImgV) {
        UIImageView * xjgdCommentIconImgV = [UIImageView new];
        self.xjgdCommentIconImgV = xjgdCommentIconImgV;
        [self addSubview:xjgdCommentIconImgV];
    }
    return _xjgdCommentIconImgV;
    
}

- (UILabel *)xjgdCommentUserNameLab{
    if (!_xjgdCommentUserNameLab) {
        UILabel * xjgdCommentUserNameLab = [UILabel new];
        self.xjgdCommentUserNameLab = xjgdCommentUserNameLab;
        [self addSubview:xjgdCommentUserNameLab];
    }
    return _xjgdCommentUserNameLab;
}

- (UILabel *)xjgdCommentContentLab{
    if (!_xjgdCommentContentLab) {
        UILabel * xjgdCommentContentLab = [UILabel new];
        self.xjgdCommentContentLab = xjgdCommentContentLab;
        [self addSubview:xjgdCommentContentLab];
    }
    return _xjgdCommentContentLab;
}

- (UILabel *)xjgdCommentTimeLab{
    if (!_xjgdCommentTimeLab) {
        UILabel * xjgdCommentTimeLab = [UILabel new];
        self.xjgdCommentTimeLab = xjgdCommentTimeLab;
        [self addSubview:xjgdCommentTimeLab];
    }
    return _xjgdCommentTimeLab;
}

- (UILabel *)xjgdCommentSpeLab{
    if (!_xjgdCommentSpeLab) {
        UILabel * xjgdCommentSpeLab = [UILabel new];
        self.xjgdCommentSpeLab = xjgdCommentSpeLab;
        [self addSubview:xjgdCommentSpeLab];
    }
    return _xjgdCommentSpeLab;
}


- (void)setupSubviews{
    
    UIView * xjgdLine = [[UIView alloc]initWithFrame:CGRectMake(ADAPTWidth(10), self.frame.size.height-0.5, KWidth - 2*ADAPTWidth(10) , 0.5)];
    xjgdLine.backgroundColor = XJCOLOR_RGB(221, 221, 221);
    [self addSubview:xjgdLine];
    
    self.xjgdCommentIconImgV.image = [UIImage imageWithColor:MAIN_COLOR];
    self.xjgdCommentIconImgV.layer.masksToBounds = YES;
    self.xjgdCommentIconImgV.layer.cornerRadius = 10;
    self.xjgdCommentIconImgV.sd_layout
    .leftSpaceToView(self, ADAPTWidth(12))
    .topSpaceToView(self, ADAPTHeight(10))
    .widthIs(20)
    .heightIs(20);
    self.xjgdCommentIconImgV.sd_cornerRadiusFromWidthRatio = @(0.5);
    
    
    self.xjgdCommentUserNameLab.font = XJFONTSET_R(14);
    self.xjgdCommentUserNameLab.textColor = XJCOLOR_RGB(17, 17, 17);
    self.xjgdCommentUserNameLab.text = @"张小花";
    CGFloat xjgdCommentUserNameLabW = [UILabel labelWithLabel:self.xjgdCommentUserNameLab
                                            getWidthWithTitle:self.xjgdCommentUserNameLab.text
                                                         font:self.xjgdCommentUserNameLab.font];
    CGFloat xjgdCommentUserNameLabH = [UILabel labelWithLabel:self.xjgdCommentUserNameLab
                                  getHeightByWidth:xjgdCommentUserNameLabW
                                             title:self.xjgdCommentUserNameLab.text
                                              font:self.xjgdCommentUserNameLab.font];
    self.xjgdCommentUserNameLab.sd_layout
    .leftSpaceToView(self.xjgdCommentIconImgV,ADAPTWidth(5))
    .centerYEqualToView(self.xjgdCommentIconImgV)
    .widthIs(xjgdCommentUserNameLabW)
    .heightIs(xjgdCommentUserNameLabH);
    
    self.xjgdCommentContentLab.font = XJFONTSET_R(12);
    self.xjgdCommentContentLab.textColor = XJCOLOR_RGB(17, 17, 17);
    self.xjgdCommentContentLab.numberOfLines = 2;
    self.xjgdCommentContentLab.text = @"和图片一模一样，专柜试穿过，160-55kg，选了S，里面不穿太厚完全没问题，M袖子略长。质量棒棒的，毛手感柔软细腻舒服太…";
    self.xjgdCommentContentLab.sd_layout
    .leftSpaceToView(self,ADAPTWidth(12))
    .topSpaceToView(self.xjgdCommentIconImgV, ADAPTHeight(5))
    .rightSpaceToView(self, ADAPTWidth(12))
    .heightIs(40);
    
    self.xjgdCommentTimeLab.font = XJFONTSET_R(12);
    self.xjgdCommentTimeLab.textColor = XJCOLOR_RGB(157, 165, 168);
    self.xjgdCommentTimeLab.text = @"2018-01-01";
    CGFloat xjgdCommentTimeLabW = [UILabel labelWithLabel:self.xjgdCommentTimeLab
                                            getWidthWithTitle:self.xjgdCommentTimeLab.text
                                                         font:self.xjgdCommentTimeLab.font];
    CGFloat xjgdCommentTimeLabH = [UILabel labelWithLabel:self.xjgdCommentTimeLab
                                             getHeightByWidth:xjgdCommentTimeLabW
                                                        title:self.xjgdCommentTimeLab.text
                                                         font:self.xjgdCommentTimeLab.font];
    self.xjgdCommentTimeLab.sd_layout
    .leftSpaceToView(self,ADAPTWidth(12))
    .topSpaceToView(self.xjgdCommentContentLab, ADAPTHeight(5))
    .widthIs(xjgdCommentTimeLabW)
    .heightIs(xjgdCommentTimeLabH);
    
    self.xjgdCommentSpeLab.font = XJFONTSET_R(12);
    self.xjgdCommentSpeLab.textColor = XJCOLOR_RGB(157, 165, 168);
    self.xjgdCommentSpeLab.text = @"套餐:套餐一；颜色:银色";
    CGFloat xjgdCommentSpeLabW = [UILabel labelWithLabel:self.xjgdCommentSpeLab
                                            getWidthWithTitle:self.xjgdCommentSpeLab.text
                                                         font:self.xjgdCommentSpeLab.font];
    CGFloat xjgdCommentSpeLabH = [UILabel labelWithLabel:self.xjgdCommentSpeLab
                                             getHeightByWidth:xjgdCommentSpeLabW
                                                        title:self.xjgdCommentSpeLab.text
                                                         font:self.xjgdCommentSpeLab.font];
    self.xjgdCommentSpeLab.sd_layout
    .leftSpaceToView(self.xjgdCommentTimeLab,ADAPTWidth(5))
    .centerYEqualToView(self.xjgdCommentTimeLab)
    .widthIs(xjgdCommentSpeLabW)
    .heightIs(xjgdCommentSpeLabH);

    
}

@end
